package gulimall.web;

import gulimall.service.SkuInfoService;
import gulimall.vo.SkuItemVo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import java.util.concurrent.ExecutionException;

/**
 * sku商品详情
 *
 * @author HLF
 * @date 2022/7/26 20:52
 */
@Controller
public class ItemController {
    @Resource
    private SkuInfoService skuInfoService;

    /**
     * 跳转到sku商品详情页面
     *
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable Long skuId, Model model) throws ExecutionException, InterruptedException {
        System.out.println("准备skuId为：" + skuId + "的商品详情");

        SkuItemVo skuItemVo = skuInfoService.getItemVo(skuId);
        model.addAttribute("item", skuItemVo);


        return "item";
    }
}
